ARRAY INDEX TO BOTTOM
This command will set the array index to the end of the array.
ARRAY INDEX TO BOTTOM Array Name(0)
Array Name(0
Integer
The name of the array followed by a pair of brackets ( ). You can also insert a value of zero, i.e. arrayname(0)
This command does not return a value.
As the size of the array can change dynamically, this command will first determine the size of the array, and then place the index at the last item.
dim a() as integer
empty array a()
print "Add 5 items to the list"
for i=1 to 5
n = rnd(1000)
print " Adding "; n; " to the list"
array insert at bottom a()
a() = n
next i
print
PrintList()
print
print "Run through the list forwards"
array index to top a()
while array index valid( a() )
print a()
next array index a()
endwhile
print
print "Run through the list backwards"
array index to bottom a()
while array index valid( a() )
print a()
previous array index a()
endwhile
print
print "Step forward to the third item and delete it"
array index to top a()
next array index a()
next array index a()
array delete element a()
PrintList()
print
print "Now insert 3 new random numbers at the top of the list"
for i=1 to 3
n = rnd(1000)
print " Adding "; n; " to the list"
array insert at top a()
a() = n
next i
print
PrintList()
print
print "Deleting every item under 500"
array index to top a()
while array index valid( a() )
if a() < 500
array delete element a()
else
next array index a()
endif
endwhile
PrintList()
wait key
end
function PrintList()
if array count( a() ) >= 0
print "The list has "; array count( a() )+1; " items"
for i=0 to array count( a() )
print " Item "; i; " = "; a(i)
next i
else
print "The list is empty"
endif
endfunction
CORE Commands Menu
Index